﻿#region

using FluentNHibernate.Mapping;

#endregion

namespace MediaSage.Lib.Database
{
    public class PersonMap : ClassMap<PersonEntity>
    {
        #region Constructors

        public PersonMap()
        {
            Table("People");
            Id(m => m.ID).GeneratedBy.GuidComb().UnsavedValue("00000000-0000-0000-0000-000000000000");
            Map(m => m.Biography).CustomSqlType("ntext");
            Map(m => m.Birthday).Nullable();
            Map(m => m.Death).Nullable();
            Map(m => m.Department);
            HasOne(m => m.Image).Cascade.All();
            HasManyToMany(m => m.Images).Table("PersonImages").ParentKeyColumn("ImagesPK").ChildKeyColumn("VideoImagePK")
                .Cascade.All();
            Map(m => m.IMDBID);
            HasMany(m => m.Job).Element("Jobs").Cascade.All();
            Map(m => m.Name);
            HasMany(m => m.Nominations).Element("Nominations").Cascade.All();
            Map(m => m.ThumbURL);
            Map(m => m.URL);
            Map(m => m.BirthPlace);
            HasMany(m => m.AlsoKnownAs).Element("AlsoKnownAs").Cascade.All();
            HasMany(m => m.Filmography).Cascade.All();
            Map(m => m.TMDBID);
            Map(m => m.TVDBID);
        }

        #endregion Constructors
    }
}